<template>
  <div class="pickingList">
    <div class="publicSearch">
      <div class="searchBar" :style="{ height: isMoreSearch ? 'auto' : '' }">
        <el-button-group>
          <el-button @click="getpickingListData" size="mini" icon="el-icon-search">查询</el-button>
          <el-button @click="clearSearchData" size="mini" icon="el-icon-refresh">重置</el-button>
        </el-button-group>
        <div>
          <span>出库任务号查询</span>
          <el-input v-model="searchData.findBySoMasterId" size="mini" placeholder="出库任务号" clearable></el-input>
        </div>
      </div>
    </div>

    <div class="tableBox none">
      <el-table
        v-loading="loading.masterTable"
        highlight-current-row
        :data="pickingLists"
        style="width: 100%"
        :row-style="Mystyle"
      >
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column fixed="left" type="index" width="50"></el-table-column>

        <el-table-column show-overflow-tooltip prop="soMasterId" label="出库任务号" min-width="120">
          <template slot-scope="scope">
            <span class="textBtn" @click="test(scope.row.soMasterId, 'item')">
              {{
              scope.row.soMasterId
              }}
            </span>
          </template>
        </el-table-column>

        <el-table-column show-overflow-tooltip prop="itemCode" label="物料编码" min-width="150">
          <template slot-scope="scope">
            <span class="textBtn" @click="test(scope.row.itemCode, 'item')">
              {{
              scope.row.itemCode
              }}
            </span>
          </template>
        </el-table-column>
        <el-table-column show-overflow-tooltip prop="itemName" label="物料名称" min-width="150">
          <template slot-scope="scope">
            <span class="textBtn" @click="test(scope.row.itemName, 'item')">
              {{
              scope.row.itemName
              }}
            </span>
          </template>
        </el-table-column>
        <el-table-column sortable show-overflow-tooltip prop="boxCode" label="容器编码" min-width="150"></el-table-column>
        <el-table-column sortable show-overflow-tooltip prop="cellCode" label="来源库位" width="180"></el-table-column>
        <el-table-column sortable show-overflow-tooltip prop="toCellCode" label="目标库位" width="180"></el-table-column>
        <el-table-column
          sortable
          show-overflow-tooltip
          prop="batchName"
          label="批次号"
          min-width="120"
        ></el-table-column>
        <el-table-column
          sortable
          show-overflow-tooltip
          prop="pickQuantity"
          label="数量"
          min-width="90"
        ></el-table-column>
        <el-table-column
          sortable
          show-overflow-tooltip
          prop="pickTime"
          label="拣货时间"
          min-width="150"
        ></el-table-column>
      </el-table>
      <el-pagination
        style="text-align: right"
        class="pagination-bottom"
        @current-change="handleCurrentChange"
        @size-change="handleSizeChange"
        :page-sizes="[10, 20, 30, 50]"
        :current-page.sync="searchData.pageNum"
        :page-size="searchData.pageSize"
        layout="sizes,total, prev, pager, next"
        :total="searchData.total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  name: "pickingList",
  data() {
    // 校验规则
    return {
      isMoreSearch: false,
      loading: {
        masterTable: true
      },
      // 用作查询的数据
      searchData: {
        // 仓库编码 获得当前仓库的编码
        wareId: PF.getLocal("wareId", "number"),
        pageNum: 1,
        pageSize: 10,
        total: null,
        findBySoMasterId: null,
      },
      searchStates: [
        {
          value: "enable",
          label: "启用"
        },
        {
          value: "disable",
          label: "禁用"
        }
      ],
      //存放装箱单数据的数组
      pickingLists: [],
      form: {
        //
      },
      rules: {
        //
      },
      formLabelWidth: "120px",
      rowData: {
        //
      },
      Mystyle: { height: "50px" },
      filterText: "",
      defaultProps: {
        children: "children",
        label: "name"
      },
      roleRowInfo: {
        //
      },
      roleForm: {
        //
      },
      roleRules: {
        //
      },
      tableRowClassName({ row, rowIndex }) {
        if (row.accountStatus === "disable") {
          return "disable-row";
        } else if (row.accountStatus === "enable") {
          return "enable-row";
        }
        return "";
      }
    };
  },
  computed: {},
  watch: {
    //
  },
  methods: {
    //分页设置每页的条数
    handleSizeChange(val) {
      this.searchData.pageSize = val;
      this.getpickingListData();
    },
    //分页设置从第几条开始
    handleCurrentChange(val) {
      this.searchData.pageNum = val;
      this.getpickingListData();
    },
    // 清空查询出库任务号
    clearSearchData() {
      this.searchData.findBySoMasterId = "";
    },
    //根据筛选条件查询数据
    getpickingListData() {
      let that = this;
      that.loading.masterTable = true;
      let searchData = JSON.parse(JSON.stringify(this.searchData));

      IOT.getServerData("/pick/tasks/picking/list", "post", searchData, ret => {
        that.loading.masterTable = false;
        if (ret.code === 200) {
          // rows就是返回的数据
          this.pickingLists = ret.rows;
          this.searchData.total = ret.total;
          this.searchData.pageNum = ret.pageNumber;
        } else {
          IOT.tips(ret.message || "服务器请求失败，稍后再试！", "error");
        }
      });
    }
    // // 进行删除
    // isDelete(id) {
    //   this.$confirm("确认删除？")
    //     .then(_ => {
    //       this.delete(id);
    //     })
    //     .catch(_ => {});
    // },
    // // 根据主键id删除
    // delete(id) {
    //   let that = this;
    //   IOT.showOverlay("删除中，请稍等...");
    //   IOT.getServerData("/pickingList/deleteById", "get", { id: id }, ret => {
    //     IOT.hideOverlay();
    //     if (ret.code === 200) {
    //       IOT.tips("删除成功！", "success", 1000, () => {
    //         that.getpickingListData();
    //       });
    //     } else {
    //       IOT.tips(ret.message || "服务器请求失败，稍后再试！", "error");
    //     }
    //   });
    // },
  },
  // 页面加载时刷新
  created() {
    // this.searchData.pageNum = 1;
    // this.searchData.pageSize = 10;
    //请求数据
    this.getpickingListData();
  }
};
</script>

<style scoped lang="less">
.pickingList {
}
</style>
